package at.main.gui;

import at.main.android.Graphics;
import at.main.util.AllImage;
import at.main.util.ManagerAudio;
import at.main.util.ManagerFont;

public class GameWinPage {
	public int iSelectMenu = 0;

	public final String k_s0 = "Về Menu";

	public final String k_s1 = "Thoát Game";
	public ManagerAudio audioWin;
	public GameWinPage() {
		audioWin = new ManagerAudio();
		iSelectMenu = 0;
		audioWin.loadSound("victory", -1);
		audioWin.playSound();
	}

	public void paint(Graphics g) {
		if(AllImage.img_bgwin !=null){
			g.drawImage(AllImage.img_bgwin, 0, 0, Graphics.TOP| Graphics.LEFT);
		}
		if (AllImage.img_lose != null) {
			g.drawImage(AllImage.img_win, MyCanvas.iWidth / 2
					- AllImage.img_win.getWidth() / 2, MyCanvas.iHeight / 2
					- AllImage.img_win.getHeight() / 2, Graphics.TOP
					| Graphics.LEFT);
		}
		ManagerFont.drawString(g, k_s0, MyCanvas.iWidth / 2,
				MyCanvas.iHeight / 2 + 20, 2, ((0 - iSelectMenu) == 0 ? 1 : 2));
		ManagerFont.drawString(g, k_s1, MyCanvas.iWidth / 2,
				MyCanvas.iHeight / 2 + 35, 2, ((1 - iSelectMenu) == 0 ? 1 : 2));		
	}

	public void update() {
		// Up
		if (MyCanvas.keyHold[2]) {
			iSelectMenu--;
			if (iSelectMenu < 0)
				iSelectMenu = 1;
		}
		if (MyCanvas.keyHold[8]) {
			iSelectMenu++;
			if (iSelectMenu > 1)
				iSelectMenu = 0;
		}
		if (MyCanvas.keyHold[5]) {
			switch (iSelectMenu) {
			case 0: // Menu
				audioWin.stopSound();
				PlayGame.isGameOver = false;
				MyCanvas.iCurrentPage = 3;
				MyCanvas.clearInput();
				break;
			case 1: // exit
				audioWin.stopSound();
				MyCanvas.iCurrentPage = MyCanvas.k_ExitGame;
				MyCanvas.clearInput();
				break;
			}
		}
		MyCanvas.clearInput();
	}
}
